Skip to content

Conversation

@rachelmcr
Copy link
Contributor

@rachelmcr rachelmcr commented May 31, 2023

Closes: #9839

Description

This PR increases the app's resilience when Product or ProductVariation fields that expect a Bool receive a String instead:

  • backordersAllowed
  • onSale

It uses failsafe decoding to handle those alternative types, and adds to the unit tests for parsing alternative types. (These are known decoding errors that users have experienced for these fields.)

Testing instructions

We don't know the exact plugins that can cause this behavior, but you can test using a tool like Charles Proxy or Proxyman to intercept and modify the response:

  1. Set a breakpoint in your tool of choice for requests to the /wc/v3/products endpoint.
  2. Build and run the app.
  3. Open the Products tab.
  4. Modify the response in one or more of the following ways:
    • A product's backorders_allowed field returns a string representing a boolean value (e.g. "backorders_allowed": "1").
    • A product's on_sale field returns a string representing a boolean value (e.g. "on_sale": "0").
  5. Execute the response and confirm the app loads the product list.

You can repeat the same steps with the variations list for a variable product, modifying the same fields in the response for a variation.


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@rachelmcr rachelmcr added feature: product list Related to the product list. feature: variation list Related to the variations list for variable products. category: reliability Related to app’s reliability, accuracy, and perceived waiting time labels May 31, 2023
@rachelmcr rachelmcr added this to the 13.9 milestone May 31, 2023
@rachelmcr rachelmcr marked this pull request as ready for review May 31, 2023 09:13
@rachelmcr rachelmcr requested review from Ecarrion and ThomazFB May 31, 2023 09:13
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 31, 2023

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr9849-c06d9fe on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@Ecarrion Ecarrion self-assigned this May 31, 2023
@peril-woocommerce
Copy link

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 2 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

@rachelmcr rachelmcr enabled auto-merge May 31, 2023 16:29
@rachelmcr rachelmcr merged commit 2f27cc7 into trunk May 31, 2023
@rachelmcr rachelmcr deleted the issue/9839-bool-decoding-fallbacks branch May 31, 2023 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: reliability Related to app’s reliability, accuracy, and perceived waiting time feature: product list Related to the product list. feature: variation list Related to the variations list for variable products.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Reliability] Add failsafe decoding for Bool when string/data is received

4 participants